package com.lingyun.ucm.web.rmi;

import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.lingyun.ucm.common.util.Constant;

/**
 * 
 * @author Terrence2013
 * 2018年1月24日 上午9:55:31
 * 项目启动初始化注册RMI服务
 */
public class RMIServerStartupListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        try {
        	//启动rmi注册表
            LocateRegistry.createRegistry(Constant.SERVER_RMI_PORT);
            //注册服务端RMI接口
            Naming.rebind(Constant.SERVER_RMI_SERVICE, new RMIServerServiceImpl());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }

}
